'''
Created on 2010-12-23

@author: zarra
'''
#!/usr/bin/env python
#coding=utf-8
'''
Created on 2010-5-10

@author: zarra
'''
from sqlalchemy import create_engine
from sqlalchemy.orm import  sessionmaker







class Session_Factory(object):
    def __init__(self,conf):
        self.engine =None
        self.Session=None
        e=conf.get('echo',True)
        path=conf.get('url',None)
        coding = conf.get('encoding','UTF-8')
        self.engine=create_engine(path,echo=e ,encoding=coding)
        self.Session = sessionmaker()
    def session(self):
        return self.Session(bind=self.engine)
    def __call__(self):
        return self.session()

    